<template>
  <div id="main">
    <h2>教学总结管理</h2>
    <div class="head">
      <el-button
        v-if="jurisdiction === '授课老师'"
        type="primary"
        style="margin: 20px"
        @click="handleOpen('添加教学总结', 1)"
      >添加教学总结</el-button>
      <el-input
        v-model="searchTableInfo"
        placeholder="请输入搜索内容"
        style="width: 240px; float: right; margin: 20px"
      />

      <div id="table-area">
        <el-table
          v-loading="listLoading"
          :data="list.slice((currentPage - 1) * pagesize, currentPage * pagesize)"
          border
          fit
          highlight-current-row
        >
          <el-table-column
            label="序号"
            type="index"
            align="center"
          >
            <template scope="scope">
              <span>{{ (currentPage - 1) * pagesize + scope.$index + 1 }}</span>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="studentName"
            label="学生姓名"
          />
          <el-table-column
            align="center"
            prop="teachSummaryStudentId"
            label="学生学号"
          />
          <el-table-column
            align="center"
            prop="studentAge"
            label="年龄"
          />
          <el-table-column
            align="center"
            prop="studentSex"
            label="学生性别"
          />
          <el-table-column
            align="center"
            prop="studentJoinTime"
            label="训练时长"
            class-name="天"
          />

          <el-table-column
            align="center"
            prop="clazzTypeName"
            label="课程类型"
          />
          <el-table-column
            align="center"
            prop="technicalTypeName"
            label="技术类型"
          />
          <el-table-column
            align="center"
            prop="teacherName"
            label="授课教师"
          />
          <el-table-column
            align="center"
            prop="principalTeacherName"
            label="主责教师"
          />

          <el-table-column
            align="center"
            min-width="100%"
            prop="teachSummaryCreatetime"
            label="录入时间"
            stripe="true"
          />
          <el-table-column
            align="center"
            prop="teachSummaryStatus"
            label="批复状态"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.teachSummaryStatus == '0'">授课老师已发布</span>
              <span v-if="scope.row.teachSummaryStatus == '1'">主责老师已批复</span>
              <span v-if="scope.row.teachSummaryStatus == '2'">教学主管已批复</span>
              <span v-if="scope.row.teachSummaryStatus == '3'">授课老师已阅读</span>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            label="操作"
          >
            <template slot-scope="Scope">
              <el-button
                v-if="jurisdiction == '授课老师' ||
                  jurisdiction == '教学主管' ||
                  jurisdiction == '责任教师'"
                type="primary"
                icon="el-icon-edit"
                @click="handleOpen('修改总结', 2, Scope.row.teachSummaryId)"
              >编辑</el-button>

              <el-button
                v-if="jurisdiction == '医疗主管' ||
                  jurisdiction == '教学主任' ||
                  jurisdiction == '教务主任'"
                type="primary"
                icon="el-icon-search"
                @click="handleOpen('修改总结', 2, Scope.row.teachSummaryId)"
              >查看</el-button>
              <el-button
                v-if="jurisdiction == ''"
                type="danger"
                icon="el-icon-delete"
                @click="handleDelete(Scope.row.teachSummaryId)"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <div id="pages">
          <el-pagination
            :current-page="currentPage"
            :page-sizes="[5, 10]"
            :page-size="pagesize"
            layout="total, sizes,prev, pager, next"
            :total="list.length"
            prev-text="上一页"
            next-text="下一页"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>

    <el-dialog
      title=""
      :close-on-click-modal="false"
      :visible.sync="dialogFormVisible"
      :before-close="handleClose"
    >
      <el-form
        ref="summary"
        :model="summary"
        label-position="top"
        :rules="rules"
      >
        <el-form-item
          prop="teachSummaryPostUserId"
          label="授课老师"
          :label-width="formLabelWidth"
        >
          <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
          <el-select
            v-model="summary.teachSummaryPostUserId"
            placeholder="请选择"
            filterable
            style="width: 100%"
          >
            <el-option
              v-for="j in staffTeacher"
              :key="j.staffId"
              :value="j.staffId"
              :label="j.String"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          prop="teachSummaryStudentId"
          label="学生"
          :label-width="formLabelWidth"
        >
          <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
          <el-select
            v-model="summary.teachSummaryStudentId"
            placeholder="请选择"
            filterable
            style="width: 100%"
          >
            <el-option
              v-for="j in child"
              :key="j.studentId"
              :value="j.studentId"
              :label="j.String"
            />
          </el-select>
        </el-form-item>

        <el-form-item
          prop="teachSummaryClazzId"
          label="班级"
          :label-width="formLabelWidth"
        >
          <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
          <el-select
            v-model="summary.teachSummaryClazzId"
            placeholder="请选择"
            filterable
            style="width: 100%"
          >
            <el-option
              v-for="j in clazz"
              :key="j.classId"
              :value="j.classId"
              :label="j.className"
            />
          </el-select>
        </el-form-item>

        <el-form-item
          prop="teachSummaryEvaluation"
          label="教学评价"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="summary.teachSummaryEvaluation"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            @input="change($event)"
          />
        </el-form-item>

        <el-form-item
          prop="teachSummaryStudentEvaluation"
          label="学生评价"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="summary.teachSummaryStudentEvaluation"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            @input="change($event)"
          />

          <el-form-item
            v-if="this.jurisdiction === '责任教师'"
            prop="teachSummaryReplyPrincipalTeacherContent"
            label="主责老师批复内容"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="summary.teachSummaryReplyPrincipalTeacherContent"
              autocomplete="off"
              maxlength="500"
              show-word-limit
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 20 }"
              placeholder="请输入内容"
              @input="change($event)"
            />
          </el-form-item>
          <el-form-item
            v-if="this.jurisdiction === '教学主管'"
            prop="teachSummaryReplyTeachingDirectorContent"
            label="教学主管批复内容"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="summary.teachSummaryReplyTeachingDirectorContent"
              autocomplete="off"
              maxlength="500"
              show-word-limit
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 20 }"
              placeholder="请输入内容"
              @input="change($event)"
            />
          </el-form-item>
          <el-form-item
            v-if="editType == 2 && (this.jurisdiction === '授课老师' || this.jurisdiction === '教学主管')"
            prop="teachSummaryReplyPrincipalTeacherContent"
            label="主责老师批复内容"
            :label-width="formLabelWidth"
          >
            {{ summary.teachSummaryReplyPrincipalTeacherContent }}
          </el-form-item>
          <el-form-item
            v-if="(editType == 2 && this.jurisdiction === '授课老师') || this.jurisdiction === '责任教师'"
            prop="teachSummaryReplyTeachingDirectorContent"
            label="教学主管批复内容"
            :label-width="formLabelWidth"
          >
            {{ summary.teachSummaryReplyTeachingDirectorContent }}
          </el-form-item>
        </el-form-item>
      </el-form>

      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          v-if="(editType == 2 && this.jurisdiction === '授课老师') || this.jurisdiction === '责任教师' || this.jurisdiction === '教学主管'"
          type="primary"
          @click="handleUpdate('summary')"
        >修 改</el-button>
        <el-button
          v-if="editType == 1 && this.jurisdiction === '授课老师'"
          type="primary"
          @click="handleAddUser('summary')"
        >添 加</el-button>
      </div>
    </el-dialog>
    <el-dialog
      v-if="this.jurisdiction === '医疗主管'"
      title=""
      :close-on-click-modal="false"
      :visible.sync="dialogFormVisible"
      :before-close="handleClose"
    >
      <el-form
        ref="summary"
        :model="summary"
        label-position="top"
        :rules="rules"
      >
        <el-form-item
          prop="teachSummaryPostUserId"
          label="授课老师"
          :label-width="formLabelWidth"
        >
          <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
          <el-tag
            type="info"
            effect="plain"
          >
            {{ SKJS }}
          </el-tag>
        </el-form-item>
        <el-form-item
          prop="teachSummaryStudentId"
          label="学生"
          :label-width="formLabelWidth"
        >
          <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
          <el-tag
            type="info"
            effect="plain"
          >
            {{ XS }}
          </el-tag>
        </el-form-item>

        <el-form-item
          prop="teachSummaryClazzId"
          label="班级"
          :label-width="formLabelWidth"
        >
          <!-- <el-input v-model="teachTodo.teachingTodoRelatedPersonnel" autocomplete="off" maxlength="20" show-word-limit /> -->
          <el-tag
            type="info"
            effect="plain"
          >
            {{ BJ }}
          </el-tag>
        </el-form-item>

        <el-form-item
          prop="teachSummaryEvaluation"
          label="教学评价"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="summary.teachSummaryEvaluation"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            readonly
            @input="change($event)"
          />
        </el-form-item>

        <el-form-item
          prop="teachSummaryStudentEvaluation"
          label="学生评价"
          :label-width="formLabelWidth"
        >
          <el-input
            v-model="summary.teachSummaryStudentEvaluation"
            autocomplete="off"
            maxlength="500"
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 20 }"
            placeholder="请输入内容"
            readonly
            @input="change($event)"
          />

          <el-form-item
            v-if="this.jurisdiction === '责任教师'"
            prop="teachSummaryReplyPrincipalTeacherContent"
            label="主责老师批复内容"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="summary.teachSummaryReplyPrincipalTeacherContent"
              autocomplete="off"
              maxlength="500"
              show-word-limit
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 20 }"
              placeholder="请输入内容"
              readonly
              @input="change($event)"
            />
          </el-form-item>
          <el-form-item
            v-if="this.jurisdiction === '教学主管'"
            prop="teachSummaryReplyTeachingDirectorContent"
            label="教学主管批复内容"
            :label-width="formLabelWidth"
          >
            <el-input
              v-model="summary.teachSummaryReplyTeachingDirectorContent"
              autocomplete="off"
              maxlength="500"
              show-word-limit
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 20 }"
              placeholder="请输入内容"
              readonly
              @input="change($event)"
            />
          </el-form-item>
          <el-form-item
            v-if="editType == 2 && (this.jurisdiction === '授课老师' || this.jurisdiction === '教学主管')"
            prop="teachSummaryReplyPrincipalTeacherContent"
            label="主责老师批复内容"
            :label-width="formLabelWidth"
          >
            {{ summary.teachSummaryReplyPrincipalTeacherContent }}
          </el-form-item>
          <el-form-item
            v-if="(editType == 2 && this.jurisdiction === '授课老师') || this.jurisdiction === '责任教师'"
            prop="teachSummaryReplyTeachingDirectorContent"
            label="教学主管批复内容"
            :label-width="formLabelWidth"
          >
            {{ summary.teachSummaryReplyTeachingDirectorContent }}
          </el-form-item>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { validateChineseName } from '@/api/validata'
import { selectStudent } from '@/api/child'
import { selectstaffTeacher } from '@/api/staff'
import store from '@/store/index'
import {
  updateteachsummary,
  deleteteachsummary,
  getAllteachsummary,
  getteachsummarybyId,
  addoneteachsummary,
  getAllteachsummaryByMedical,
  getAllteachsummaryByDirector,
  getAllteachsummaryByprincipal,
  getAllteachsummaryAA,
  selectclazz,
  upateStatus,
  upateStatusA,
  upateStatusB,
  updateteachsummaryA,
  updateteachsummaryB
} from '@/api/teachsummary'
import moment from 'moment'
import Vue from 'vue'
import Plugin from 'v-fit-columns'
Vue.use(Plugin)
export default {
  data () {
    return {
      SKJS: [],
      BJ: [],
      XS: [],
      jurisdiction: '',
      BB: store.getters.userId,
      value: '',
      clazz: [],
      currentPage: 1, // 默认显示页面为1
      pagesize: 5, //    每页的数据条数
      tableList: [],
      searchTableInfo: '',
      summary: {},
      aaa: {},
      teachStatus: '',
      child: {},
      listLoading: false,
      dialogFormVisible: false,
      editType: 1, // 1 添加 2 修改
      student: {},
      search: '',
      staffTeacher: [],
      teachCreatetime: '',
      formLabelWidth: '200px',
      rules: {
        teachSummaryPostUserId: [
          { required: true, message: '授课教师不能为空', trigger: 'blur' }

        ],

        teachSummaryStudentId: [{ required: true, message: '学生不能为空', trigger: 'blur' }],
        teachSummaryClazzId: [{ required: true, message: '班级不能为空', trigger: 'blur' }],
        teachSummaryEvaluation: [{ required: true, message: '教学评价不能为空', trigger: 'blur' }],
        teachSummaryStudentEvaluation: [{ required: true, message: '学生评价评价不能为空', trigger: 'blur' }]

      },
      newsummary: {
        teachCreatetime: ''
        // teachId: ""
      }
    }
  },
  computed: {
    // 根据计算属性模糊搜索
    list () {
      const searchTableInfo = this.searchTableInfo
      if (searchTableInfo) {
        // filter() 方法创建一个新的数组，新数组中的元素是通过检查指定数组中符合条件的所有元素。
        // 注意： filter() 不会对空数组进行检测。
        // 注意： filter() 不会改变原始数组。
        return this.tableList.filter((data) => {
          // some() 方法用于检测数组中的元素是否满足指定条件;
          // some() 方法会依次执行数组的每个元素：
          // 如果有一个元素满足条件，则表达式返回true , 剩余的元素不会再执行检测;
          // 如果没有满足条件的元素，则返回false。
          // 注意： some() 不会对空数组进行检测。
          // 注意： some() 不会改变原始数组。
          return Object.keys(data).some((key) => {
            // indexOf() 返回某个指定的字符在某个字符串中首次出现的位置，如果没有找到就返回-1；
            // 该方法对大小写敏感！所以之前需要toLowerCase()方法将所有查询到内容变为小写。
            return String(data[key]).toLowerCase().indexOf(searchTableInfo) > -1
          })
        })
      }
      return this.tableList
    }
  },
  created () {
    this.jurisdiction = store.getters.roles[0]
    this.fetchData()
    // this.getAllstudent();
    this.getinfo()
  },
  methods: {
    // 时间格式化
    dateFormat (row, column) {
      var date = row[column.property]
      if (date === undefined) {
        return ''
      }
      return moment(date).format('YYYY-MM-DD HH:mm:ss')
    },
    // 时间格式化
    change (e) {
      this.$forceUpdate()
    },
    // formatSex: function(row, column, cellValue) {
    //   if (cellValue === '1') {
    //     return '女'
    //   } else if (cellValue === '0') {
    //     return '男'
    //   }
    // },

    // 每页下拉显示数据
    handleSizeChange: function (size) {
      this.pagesize = size
    },
    // 点击第几页
    handleCurrentChange: function (currentPage) {
      this.currentPage = currentPage
    },
    // getAllstudent() {
    //   getAllstudentName().then(res => {
    //     this.student = res.obj;
    //   });
    // },
    getinfo: function () {
      selectStudent().then((resp) => {
        // console.log(resp.data.records)
        this.child = resp.data.records
      })
      selectstaffTeacher().then((resp) => {
        // console.log(resp.data.records, '获取所有教师')
        this.staffTeacher = resp.data.records
      })
      selectclazz().then((resp) => {
        this.clazz = resp.data.records
      })
    },
    handleClick (row) { },
    fetchData () {
      this.tableList = []
      this.listLoading = true
      if (this.jurisdiction === '医疗主管') {
        getAllteachsummaryByMedical(this.BB).then((data) => {
          this.newsummary
          for (var i = 0; i < data.data.records.length; i++) {
            this.newsummary.clazzTypeName = data.data.records[i].clazzTypeName
            this.newsummary.principalTeacherName = data.data.records[i].principalTeacherName
            this.newsummary.studentAge = data.data.records[i].studentAge
            this.newsummary.studentJoinTime = data.data.records[i].studentJoinTime
            this.newsummary.studentName = data.data.records[i].studentName
            this.newsummary.studentSex = data.data.records[i].studentSex
            this.newsummary.technicalTypeName = data.data.records[i].technicalTypeName
            this.newsummary.teacherName = data.data.records[i].teacherName
            this.newsummary.teachSummaryCreatetime = data.data.records[i].teachSummaryCreatetime
            this.newsummary.teachStuid = data.data.records[i].teachStuid
            this.newsummary.teachSummaryId = data.data.records[i].teachSummaryId
            this.newsummary.teachSummaryStatus = data.data.records[i].teachSummaryStatus
            this.newsummary.teachSummaryStudentId = data.data.records[i].teachSummaryStudentId
            this.tableList.push(this.newsummary)
            this.newsummary = {}
          }

          this.listLoading = false
        })
      } else if (this.jurisdiction === '教学主任') {
        getAllteachsummaryAA(this.BB).then((data) => {
          this.newsummary
          for (var i = 0; i < data.data.records.length; i++) {
            this.newsummary.clazzTypeName = data.data.records[i].clazzTypeName
            this.newsummary.principalTeacherName = data.data.records[i].principalTeacherName
            this.newsummary.studentAge = data.data.records[i].studentAge
            this.newsummary.studentJoinTime = data.data.records[i].studentJoinTime
            this.newsummary.studentName = data.data.records[i].studentName
            this.newsummary.studentSex = data.data.records[i].studentSex
            this.newsummary.technicalTypeName = data.data.records[i].technicalTypeName
            this.newsummary.teacherName = data.data.records[i].teacherName
            this.newsummary.teachSummaryCreatetime = data.data.records[i].teachSummaryCreatetime
            this.newsummary.teachStuid = data.data.records[i].teachStuid
            this.newsummary.teachSummaryId = data.data.records[i].teachSummaryId
            this.newsummary.teachSummaryStatus = data.data.records[i].teachSummaryStatus
            this.newsummary.teachSummaryStudentId = data.data.records[i].teachSummaryStudentId
            this.tableList.push(this.newsummary)
            this.newsummary = {}
          }

          this.listLoading = false
        })
      } else if (this.jurisdiction === '责任教师') {
        getAllteachsummaryByprincipal(this.BB).then((data) => {
          this.newsummary
          for (var i = 0; i < data.data.records.length; i++) {
            this.newsummary.clazzTypeName = data.data.records[i].clazzTypeName
            this.newsummary.principalTeacherName = data.data.records[i].principalTeacherName
            this.newsummary.studentAge = data.data.records[i].studentAge
            this.newsummary.studentJoinTime = data.data.records[i].studentJoinTime
            this.newsummary.studentName = data.data.records[i].studentName
            this.newsummary.studentSex = data.data.records[i].studentSex
            this.newsummary.technicalTypeName = data.data.records[i].technicalTypeName
            this.newsummary.teacherName = data.data.records[i].teacherName
            this.newsummary.teachSummaryCreatetime = data.data.records[i].teachSummaryCreatetime
            this.newsummary.teachStuid = data.data.records[i].teachStuid
            this.newsummary.teachSummaryId = data.data.records[i].teachSummaryId
            this.newsummary.teachSummaryStatus = data.data.records[i].teachSummaryStatus
            this.newsummary.teachSummaryStudentId = data.data.records[i].teachSummaryStudentId

            this.tableList.push(this.newsummary)
            this.newsummary = {}
          }

          this.listLoading = false
        })
      } else if (this.jurisdiction === '教学主管') {
        getAllteachsummaryByDirector(this.BB).then((data) => {
          // console.log(data.obj)
          this.newsummary
          for (var i = 0; i < data.data.records.length; i++) {
            this.newsummary.clazzTypeName = data.data.records[i].clazzTypeName
            this.newsummary.principalTeacherName = data.data.records[i].principalTeacherName
            this.newsummary.studentAge = data.data.records[i].studentAge
            this.newsummary.studentJoinTime = data.data.records[i].studentJoinTime
            this.newsummary.studentName = data.data.records[i].studentName
            this.newsummary.studentSex = data.data.records[i].studentSex
            this.newsummary.technicalTypeName = data.data.records[i].technicalTypeName
            this.newsummary.teacherName = data.data.records[i].teacherName
            this.newsummary.teachSummaryCreatetime = data.data.records[i].teachSummaryCreatetime
            this.newsummary.teachStuid = data.data.records[i].teachStuid
            this.newsummary.teachSummaryId = data.data.records[i].teachSummaryId
            this.newsummary.teachSummaryStatus = data.data.records[i].teachSummaryStatus
            this.newsummary.teachSummaryStudentId = data.data.records[i].teachSummaryStudentId
            this.tableList.push(this.newsummary)
            this.newsummary = {}
          }
          this.listLoading = false
        })
      } else {
        getAllteachsummary(this.BB).then((data) => {
          // console.log(data, 'data的数据')
          this.newsummary
          for (var i = 0; i < data.data.records.length; i++) {
            this.newsummary.clazzTypeName = data.data.records[i].clazzTypeName
            this.newsummary.principalTeacherName = data.data.records[i].principalTeacherName
            this.newsummary.studentAge = data.data.records[i].studentAge
            this.newsummary.studentJoinTime = data.data.records[i].studentJoinTime
            this.newsummary.studentName = data.data.records[i].studentName
            this.newsummary.studentSex = data.data.records[i].studentSex
            this.newsummary.technicalTypeName = data.data.records[i].technicalTypeName
            this.newsummary.teacherName = data.data.records[i].teacherName
            this.newsummary.teachSummaryCreatetime = data.data.records[i].teachSummaryCreatetime
            this.newsummary.teachStuid = data.data.records[i].teachStuid
            this.newsummary.teachSummaryId = data.data.records[i].teachSummaryId
            this.newsummary.teachSummaryStatus = data.data.records[i].teachSummaryStatus
            this.newsummary.teachSummaryStudentId = data.data.records[i].teachSummaryStudentId
            this.tableList.push(this.newsummary)
            this.newsummary = {}
          }

          this.listLoading = false
        })
      }
    },
    handleDelete (id) {
      this.$confirm('确认删除该项总结？').then(() =>
        deleteteachsummary(id).then((data) => {
          this.$notify({
            title: '操作成功',
            type: 'success'
          })
          const totalPage = Math.ceil((this.tableList.length - 1) / this.pagesize)
          const page = this.currentPage > totalPage ? totalPage : this.currentPage
          this.currentPage = this.currentPage < 1 ? 1 : page
          this.fetchData()
        })
      )
    },
    handleAddUser (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          addoneteachsummary(this.summary, this.BB).then((resp) => {
            // console.log(this.BB)
            this.$notify({
              title: '操作成功',
              type: 'success'
            })
            this.fetchData()
          })
          this.summary = {}
          this.dialogFormVisible = false
          return true
        } else {
          this.$notify({
            title: '请正确填写',
            type: 'error'
          })
          return false
        }
      })
    },
    handleOpen (title, type, id) {
      this.summary = {}
      this.dialogFormVisible = true
      this.title = title
      this.editType = type
      // console.log(id)
      if (type === 2) {
        getteachsummarybyId(id).then((resp) => {
          console.log(resp, '点击编辑查看的信息')
          this.summary = resp.data.records
          this.summary.teachSummaryEvaluation = resp.data.records.teachSummaryEvaluation
          this.summary.teachStudentEvaluation = resp.data.records.teachStudentEvaluation
          this.summary.teachSummaryId = resp.data.records.teachSummaryId
          this.summary.teachSummaryClazzId = resp.data.records.teachSummaryClazzId
          this.summary.teachSummaryStudentId = resp.data.records.teachSummaryStudentId
          this.summary.teachSummaryPostUserId = resp.data.records.teachSummaryPostUserId
          this.summary.teachSummaryStatus = resp.data.records.teachSummaryStatus
          this.summary.teachSummaryReplyPrincipalTeacherContent = resp.data.records.teachSummaryReplyPrincipalTeacherContent
          this.summary.teachSummaryReplyTeachingDirectorContent = resp.data.records.teachSummaryReplyTeachingDirectorContent
          this.aaa.teachSummaryId = resp.data.records.teachSummaryId
          this.aaa.teachSummaryStatus = resp.data.records.teachSummaryStatus
          if (this.jurisdiction === '授课老师') {
            if (this.summary.teachSummaryStatus === 2) {
              // console.log('进来了')
              upateStatus(this.summary).then((resp) => {
                this.fetchData()
              })
            }
          }
          if (this.jurisdiction === '医疗主管') {
            for (let i3 = 0; i3 < this.clazz.length; i3++) {
              if (this.summary.teachSummaryClazzId == this.clazz[i3].classId) {
                this.BJ = this.clazz[i3].className
              }
            }
            for (let i4 = 0; i4 < this.child.length; i4++) {
              if (this.summary.teachSummaryStudentId == this.child[i4].studentId) {
                this.XS = this.child[i4].String
              }
            }
            for (let i6 = 0; i6 < this.staffTeacher.length; i6++) {
              if (this.summary.teachSummaryPostUserId == this.staffTeacher[i6].staffId) {
                this.SKJS = this.staffTeacher[i6].String
              }
            }
          }
        })
        this.dialogFormVisible = true
      } else {
        this.dialogFormVisible = true
      }
    },
    handleClose () {
      this.dialogFormVisible = false
      this.summary = {}
      this.aaa = {}
    },

    handleUpdate (formName) {
      this.$refs[formName].validate((valid) => {
        if (this.jurisdiction === '责任教师') {
          if (this.aaa.teachSummaryStatus === 0) {
            upateStatusA(this.aaa).then((resp) => { })
          }
        }
        if (this.jurisdiction === '教学主管') {
          if (this.aaa.teachSummaryStatus === 1) {
            upateStatusB(this.aaa).then((resp) => { })
          }
        }

        if (valid) {
          if (this.jurisdiction === '责任教师') {
            updateteachsummaryA(this.summary, this.BB).then((resp) => {
              this.$notify({
                title: '修改成功',
                type: 'success'
              })
              this.fetchData()
            })
          } else if (this.jurisdiction === '教学主管') {
            updateteachsummaryB(this.summary, this.BB).then((resp) => {
              this.$notify({
                title: '修改成功',
                type: 'success'
              })
              this.fetchData()
            })
          } else if (this.jurisdiction !== '责任教师' || this.jurisdiction !== '教学主管') {
            updateteachsummary(this.summary).then((resp) => {
              this.$notify({
                title: '修改成功',
                type: 'success'
              })
              this.fetchData()
            })
          }

          this.dialogFormVisible = false
          return true
        } else {
          this.$notify({
            title: '请正确填写',
            type: 'error'
          })
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
#main {
  margin-left: 5px;
  margin-right: 5px;
}
#table-area {
  margin-left: 10px;
  margin-right: 10px;
}
</style>
